import Vue from 'vue'
import VueRouter from 'vue-router'
import movie from '../views/home/movie.vue'

Vue.use(VueRouter)

const routes = [
        { path: "/", redirect: "/movie" },
        {
            path: '/movie',
            name: 'movie',
            component: movie,
            //配置子路由
            children: [{
                    path: "hot",
                    name: "hot",
                    component: () =>
                        import ( /* webpackChunkName: "hot" */ '../views/home/hot.vue')
                },
                {
                    path: "cinema",
                    name: "cinema",
                    component: () =>
                        import ( /* webpackChunkName: "cinema" */ '../views/home/cinema.vue')
                },
                {
                    path: "wait",
                    name: "wait",
                    component: () =>
                        import ( /* webpackChunkName: "wait" */ '../views/home/wait.vue')
                },
                {
                    path: "classic",
                    name: "classic",
                    component: () =>
                        import ( /* webpackChunkName: "classic" */ '../views/home/classic.vue')
                }
            ]
        },
        {
            path: '/myvideo',
            name: 'myvideo',
            //路由懒加载，路由到哪个页面就加载哪个页面的组件，优化性能，可以使首页加载速度变快
            component: () =>
                import ( /* webpackChunkName: "video" */ '../views/myvideo.vue')
        },
        {
            path: '/shortvideo',
            name: 'shortvideo',
            component: () =>
                import ( /* webpackChunkName: "video" */ '../views/shortvideo.vue')
        },
        {
            path: '/show',
            name: 'show',
            component: () =>
                import ( /* webpackChunkName: "video" */ '../views/show.vue')
        },
        {
            path: '/login',
            name: 'login',
            component: () =>
                import ( /* webpackChunkName: "video" */ '../views/login.vue')
        },
        //item的路由,动态路由
        {
            path: '/item/:id',
            name: 'item',
            component: () =>
                import ( /* webpackChunkName: "item" */ '../views/item.vue')
        },
    ]
    //创建路由实例
const router = new VueRouter({
    routes
})

export default router